import React, { Component } from 'react'
import './tabControl/style.css'

export class TabControl extends Component {
  constructor() {
    super()
    this.state = {
      currentIndex: 0,
    }
  }
  render() {
    const { titles } = this.props
    const { currentIndex } = this.state
    return (
      <div className="tab-control">
        {titles.map((item, index) => {
          return (
            <div
              className={`item  ${index === currentIndex ? 'active' : ''}`}
              key={item}
            >
              <span className="text">{item}</span>
            </div>
          )
        })}
      </div>
    )
  }
}

export default TabControl
